
#ifndef Environment_h
#define Environment_h

#include <REvents.h>
#include <System/EventArgs.h>
#include <System/String.h>
#include <System/Version.h>
#include <System/OperatingSystem.h>
#include <System/EnvironmentVariableTarget.h>
#include <System/Collections/IDictionary.h>

#include <Typedef.h>
#include <CSharpPropertyMethods.h>
#include <Defines.h>

namespace Riccsson
{
	namespace System
	{

		// Summary:
		//     Provides information about, and means to manipulate, the current environment
		//     and platform. This class cannot be inherited.
		class Environment sealed
		{
			// Summary:
			//     Specifies enumerated constants used to retrieve directory paths to system
			//     special folders.
			public: enum class SpecialFolder
			{
				// Summary:
				//     The logical Desktop rather than the physical file system location.
				Desktop = 0,
				//
				// Summary:
				//     The directory that contains the user's program groups.
				Programs = 2,
				//
				// Summary:
				//     The directory that serves as a common repository for documents.
				Personal = 5,
				//
				// Summary:
				//     The My Documents folder.
				MyDocuments = 5,
				//
				// Summary:
				//     The directory that serves as a common repository for the user's favorite
				//     items.
				Favorites = 6,
				//
				// Summary:
				//     The directory that corresponds to the user's Startup program group.
				Startup = 7,
				//
				// Summary:
				//     The directory that contains the user's most recently used documents.
				Recent = 8,
				//
				// Summary:
				//     The directory that contains the Send To menu items.
				SendTo = 9,
				//
				// Summary:
				//     The directory that contains the Start menu items.
				StartMenu = 11,
				//
				// Summary:
				//     The My Music folder.
				MyMusic = 13,
				//
				// Summary:
				//     The file system directory that serves as a repository for videos that belong
				//     to a user.
				MyVideos = 14,
				//
				// Summary:
				//     The directory used to physically store file objects on the desktop.
				DesktopDirectory = 16,
				//
				// Summary:
				//     The My Computer folder.
				MyComputer = 17,
				//
				// Summary:
				//     A file system directory that contains the link objects that may exist in
				//     the My Network Places virtual folder.
				NetworkShortcuts = 19,
				//
				// Summary:
				//     A virtual folder that contains fonts.
				Fonts = 20,
				//
				// Summary:
				//     The directory that serves as a common repository for document templates.
				Templates = 21,
				//
				// Summary:
				//     The file system directory that contains the programs and folders that appear
				//     on the Start menu for all users. This special folder is valid only for Windows
				//     NT systems.
				CommonStartMenu = 22,
				//
				// Summary:
				//     A folder for components that are shared across applications. This special
				//     folder is valid only for Windows NT, Windows 2000, and Windows XP systems.
				CommonPrograms = 23,
				//
				// Summary:
				//     The file system directory that contains the programs that appear in the Startup
				//     folder for all users. This special folder is valid only for Windows NT systems.
				CommonStartup = 24,
				//
				// Summary:
				//     The file system directory that contains files and folders that appear on
				//     the desktop for all users. This special folder is valid only for Windows
				//     NT systems.
				CommonDesktopDirectory = 25,
				//
				// Summary:
				//     The directory that serves as a common repository for application-specific
				//     data for the current roaming user.
				ApplicationData = 26,
				//
				// Summary:
				//     The file system directory that contains the link objects that can exist in
				//     the Printers virtual folder.
				PrinterShortcuts = 27,
				//
				// Summary:
				//     The directory that serves as a common repository for application-specific
				//     data that is used by the current, non-roaming user.
				LocalApplicationData = 28,
				//
				// Summary:
				//     The directory that serves as a common repository for temporary Internet files.
				InternetCache = 32,
				//
				// Summary:
				//     The directory that serves as a common repository for Internet cookies.
				Cookies = 33,
				//
				// Summary:
				//     The directory that serves as a common repository for Internet history items.
				History = 34,
				//
				// Summary:
				//     The directory that serves as a common repository for application-specific
				//     data that is used by all users.
				CommonApplicationData = 35,
				//
				// Summary:
				//     The Windows directory or SYSROOT. This corresponds to the %windir% or %SYSTEMROOT%
				//     environment variables.
				windows = 36,
				//
				// Summary:
				//     The System directory.
				System = 37,
				//
				// Summary:
				//     The program files directory.
				ProgramFiles = 38,
				//
				// Summary:
				//     The My Pictures folder.
				MyPictures = 39,
				//
				// Summary:
				//     The user's profile folder. Applications should not create files or folders
				//     at this level; they should put their data under the locations referred to
				//     by System.Environment.SpecialFolder.ApplicationData.
				UserProfile = 40,
				//
				// Summary:
				//     The Windows System folder.
				SystemX86 = 41,
				//
				// Summary:
				//     The Program Files folder.
				ProgramFilesX86 = 42,
				//
				// Summary:
				//     The directory for components that are shared across applications.
				CommonProgramFiles = 43,
				//
				// Summary:
				//     The Program Files folder.
				CommonProgramFilesX86 = 44,
				//
				// Summary:
				//     The file system directory that contains the templates that are available
				//     to all users. This special folder is valid only for Windows NT systems.
				CommonTemplates = 45,
				//
				// Summary:
				//     The file system directory that contains documents that are common to all
				//     users. This special folder is valid for Windows NT systems, Windows 95, and
				//     Windows 98 systems with Shfolder.dll installed.
				CommonDocuments = 46,
				//
				// Summary:
				//     The file system directory that contains administrative tools for all users
				//     of the computer.
				CommonAdminTools = 47,
				//
				// Summary:
				//     The file system directory that is used to store administrative tools for
				//     an individual user. The Microsoft Management Console (MMC) will save customized
				//     consoles to this directory, and it will roam with the user.
				AdminTools = 48,
				//
				// Summary:
				//     The file system directory that serves as a repository for music files common
				//     to all users.
				CommonMusic = 53,
				//
				// Summary:
				//     The file system directory that serves as a repository for image files common
				//     to all users.
				CommonPictures = 54,
				//
				// Summary:
				//     The file system directory that serves as a repository for video files common
				//     to all users.
				CommonVideos = 55,
				//
				// Summary:
				//     The file system directory that contains resource data.
				Resources = 56,
				//
				// Summary:
				//     The file system directory that contains localized resource data.
				LocalizedResources = 57,
				//
				// Summary:
				//     This value is recognized in Windows Vista for backward compatibility, but
				//     the special folder itself is no longer used.
				CommonOemLinks = 58,
				//
				// Summary:
				//     The file system directory that acts as a staging area for files waiting to
				//     be written to a CD.
				CDBurning = 59,
			};

			// Summary:
			//     Specifies options to use for getting the path to a special folder.
			public: enum class SpecialFolderOption
			{
				// Summary:
				//     The path to the folder is verified. If the folder exists, the path is returned.
				//     If the folder does not exist, an empty GC_PTR<string> is returned. This is the default
				//     behavior.
				None = 0,
				//
				// Summary:
				//     The path to the folder is returned without verifying whether the path exists.
				//     If the folder is located on a network, specifying this option can reduce
				//     lag time.
				DoNotVerify = 16384,
				//
				// Summary:
				//     The path to the folder is created if it does not already exist.
				Create = 32768,
			};

			private: Environment(){}
					 
			PROP3GET_STATIC(Environment, GC_PTR<string>, CommandLine)
			PROP3_STATIC(Environment, GC_PTR<string>, CurrentDirectory)
			PROP3GET_STATIC(Environment, int, CurrentManagedThreadId)
			PROP3_STATIC(Environment, int, ExitCode)
			PROP3GET_STATIC(Environment, bool, HasShutdownStarted)
			PROP3GET_STATIC(Environment, bool, Is64BitOperatingSystem)
			PROP3GET_STATIC(Environment, bool, Is64BitProcess)
			PROP3GET_STATIC(Environment, GC_PTR<string>, MachineName)
			PROP3GET_STATIC(Environment, GC_PTR<string>, NewLine)
			PROP3GET_STATIC(Environment, GC_PTR<OperatingSystem>, OSVersion)
			PROP3GET_STATIC(Environment, int, ProcessorCount)
			PROP3GET_STATIC(Environment, GC_PTR<string>, StackTrace)
			PROP3GET_STATIC(Environment, GC_PTR<string>, SystemDirectory)
			PROP3GET_STATIC(Environment, int, TickCount)

			// Summary:
			//     Gets the command line for this process.
			//
			// Returns:
			//     A GC_PTR<string> containing command-line arguments.
			public: static PROP3_GET(GC_PTR<string>, CommandLine);

			//
			// Summary:
			//     Gets or sets the fully qualified path of the current working directory.
			//
			// Returns:
			//     A GC_PTR<string> containing a directory path.
			//
			// Exceptions:
			//   System.ArgumentException:
			//     Attempted to set to an empty GC_PTR<string> ("").
			//
			//   System.ArgumentNullException:
			//     Attempted to set to null.
			//
			//   System.IO.IOException:
			//     An I/O error occurred.
			//
			//   System.IO.DirectoryNotFoundException:
			//     Attempted to set a local path that cannot be found.
			//
			//   System.Security.SecurityException:
			//     The caller does not have the appropriate permission.
			public: static PROP3_GET(GC_PTR<string>, CurrentDirectory);
			public: static PROP3_SET(GC_PTR<string>, CurrentDirectory);

			//
			// Summary:
			//     Gets a unique identifier for the current managed thread.
			//
			// Returns:
			//     An integer that represents a unique identifier for this managed thread.
			public: static PROP3_GET(int, CurrentManagedThreadId);

			//
			// Summary:
			//     Gets or sets the exit code of the process.
			//
			// Returns:
			//     A 32-bit signed integer containing the exit code. The default value is zero.
			public: static PROP3_GET(int, ExitCode);
			public: static PROP3_SET(int, ExitCode);

			//
			// Summary:
			//     Gets a value indicating whether the common language runtime (CLR) is shutting
			//     down.
			//
			// Returns:
			//     true if the CLR is shutting down; otherwise, false.
			public: static PROP3_GET(bool, HasShutdownStarted);

			//
			// Summary:
			//     Determines whether the current operating system is a 64-bit operating system.
			//
			// Returns:
			//     true if the operating system is 64-bit; otherwise, false.
			public: static PROP3_GET(bool, Is64BitOperatingSystem);

			//
			// Summary:
			//     Determines whether the current process is a 64-bit process.
			//
			// Returns:
			//     true if the process is 64-bit; otherwise, false.
			public: static PROP3_GET(bool, Is64BitProcess);

			//
			// Summary:
			//     Gets the NetBIOS name of this local computer.
			//
			// Returns:
			//     A GC_PTR<string> containing the name of this computer.
			//
			// Exceptions:
			//   System.InvalidOperationException:
			//     The name of this computer cannot be obtained.
			public: static PROP3_GET(GC_PTR<string>, MachineName);

			//
			// Summary:
			//     Gets the newline GC_PTR<string> defined for this environment.
			//
			// Returns:
			//     A GC_PTR<string> containing "\r\n" for non-Unix platforms, or a GC_PTR<string> containing
			//     "\n" for Unix platforms.
			public: static PROP3_GET(GC_PTR<string>, NewLine);

			//
			// Summary:
			//     Gets an System.OperatingSystem object that contains the current platform
			//     identifier and version number.
			//
			// Returns:
			//     An object that contains the platform identifier and version number.
			//
			// Exceptions:
			//   System.InvalidOperationException:
			//     This property was unable to obtain the system version.-or- The obtained platform
			//     identifier is not a member of System.PlatformID
			public: static PROP3_GET(GC_PTR<OperatingSystem>, OSVersion);

			//
			// Summary:
			//     Gets the number of processors on the current machine.
			//
			// Returns:
			//     The 32-bit signed integer that specifies the number of processors on the
			//     current machine. There is no default. If the current machine contains multiple
			//     processor groups, this property returns the number of logical processors
			//     that are available for use by the common language runtime (CLR).
			public: static PROP3_GET(int, ProcessorCount);

			//
			// Summary:
			//     Gets current stack trace information.
			//
			// Returns:
			//     A GC_PTR<string> containing stack trace information. This value can be System.String.Empty.
			//
			// Exceptions:
			//   System.ArgumentOutOfRangeException:
			//     The requested stack trace information is out of range.
			public: static PROP3_GET(GC_PTR<string>, StackTrace);

			//
			// Summary:
			//     Gets the fully qualified path of the system directory.
			//
			// Returns:
			//     A GC_PTR<string> containing a directory path.
			public: static PROP3_GET(GC_PTR<string>, SystemDirectory);

			//
			// Summary:
			//     Gets the amount of memory for an operating system's page file.
			//
			// Returns:
			//     The number of bytes in a system page file.
			public: static PROP3_GET(int, SystemPageSize);

			//
			// Summary:
			//     Gets the number of milliseconds elapsed since the system started.
			//
			// Returns:
			//     A 32-bit signed integer containing the amount of time in milliseconds that
			//     has passed since the last time the computer was started.
			public: static PROP3_GET(int, TickCount);

			//
			// Summary:
			//     Gets the network domain name associated with the current user.
			//
			// Returns:
			//     The network domain name associated with the current user.
			//
			// Exceptions:
			//   System.PlatformNotSupportedException:
			//     The operating system does not support retrieving the network domain name.
			//
			//   System.InvalidOperationException:
			//     The network domain name cannot be retrieved.
			public: static PROP3_GET(GC_PTR<string>, UserDomainName);

			//
			// Summary:
			//     Gets a value indicating whether the current process is running in user interactive
			//     mode.
			//
			// Returns:
			//     true if the current process is running in user interactive mode; otherwise,
			//     false.
			public: static PROP3_GET(bool, UserInteractive);

			//
			// Summary:
			//     Gets the user name of the person who is currently logged on to the Windows
			//     operating system.
			//
			// Returns:
			//     The user name of the person who is logged on to Windows.
			public: static PROP3_GET(GC_PTR<string>, UserName);

			//
			// Summary:
			//     Gets a System.Version object that describes the major, minor, build, and
			//     revision numbers of the common language runtime.
			//
			// Returns:
			//     An object that displays the version of the common language runtime.
			public: static PROP3_GET(GC_PTR<Version>, version);

			//
			// Summary:
			//     Gets the amount of physical memory mapped to the process context.
			//
			// Returns:
			//     A 64-bit signed integer containing the number of bytes of physical memory
			//     mapped to the process context.
			public: static PROP3_GET(long, WorkingSet);

			// Summary:
			//     Terminates this process and gives the underlying operating system the specified
			//     exit code.
			//
			// Parameters:
			//   exitCode:
			//     Exit code to be given to the operating system.
			//
			// Exceptions:
			//   System.Security.SecurityException:
			//     The caller does not have sufficient security permission to perform this function.
			//[SecuritySafeCritical]
			public: static void Exit(int exitCode);

			//
			// Summary:
			//     Replaces the name of each environment variable embedded in the specified
			//     GC_PTR<string> with the GC_PTR<string> equivalent of the value of the variable, then returns
			//     the resulting string.
			//
			// Parameters:
			//   name:
			//     A GC_PTR<string> containing the names of zero or more environment variables. Each
			//     environment variable is quoted with the percent sign character (%).
			//
			// Returns:
			//     A GC_PTR<string> with each environment variable replaced by its value.
			//
			// Exceptions:
			//   System.ArgumentNullException:
			//     name is null.
			//[SecuritySafeCritical]
			public: static GC_PTR<string> ExpandEnvironmentVariables(string* name);

			//
			// Summary:
			//     Immediately terminates a process after writing a message to the Windows Application
			//     event log, and then includes the message in error reporting to Microsoft.
			//
			// Parameters:
			//   message:
			//     A message that explains why the process was terminated, or null if no explanation
			//     is provided.
			//[SecurityCritical]
			public: static void FailFast(string* message);

			//
			// Summary:
			//     Immediately terminates a process after writing a message to the Windows Application
			//     event log, and then includes the message and exception information in error
			//     reporting to Microsoft.
			//
			// Parameters:
			//   message:
			//     A message that explains why the process was terminated, or null if no explanation
			//     is provided.
			//
			//   exception:
			//     An exception that represents the error that caused the termination. This
			//     is typically the exception in a catch block.
			//[SecurityCritical]
			public: static void FailFast(string* message, Exception* exception);

			//
			// Summary:
			//     Returns a GC_PTR<string> array containing the command-line arguments for the current
			//     process.
			//
			// Returns:
			//     An array of GC_PTR<string> where each element contains a command-line argument. The
			//     first element is the executable file name, and the following zero or more
			//     elements contain the remaining command-line arguments.
			//
			// Exceptions:
			//   System.NotSupportedException:
			//     The system does not support command-line arguments.
			//[SecuritySafeCritical]
			public: static GC_PTR<Array<string>> GetCommandLineArgs();

			//
			// Summary:
			//     Retrieves the value of an environment variable from the current process.
			//
			// Parameters:
			//   variable:
			//     The name of the environment variable.
			//
			// Returns:
			//     The value of the environment variable specified by variable, or null if the
			//     environment variable is not found.
			//
			// Exceptions:
			//   System.ArgumentNullException:
			//     variable is null.
			//
			//   System.Security.SecurityException:
			//     The caller does not have the required permission to perform this operation.
			//[SecuritySafeCritical]
			public: static GC_PTR<string> GetEnvironmentVariable(string* variable);

			//
			// Summary:
			//     Retrieves the value of an environment variable from the current process or
			//     from the Windows operating system registry key for the current user or local
			//     machine.
			//
			// Parameters:
			//   variable:
			//     The name of an environment variable.
			//
			//   target:
			//     One of the System.EnvironmentVariableTarget values.
			//
			// Returns:
			//     The value of the environment variable specified by the variable and target
			//     parameters, or null if the environment variable is not found.
			//
			// Exceptions:
			//   System.ArgumentNullException:
			//     variable is null.
			//
			//   System.NotSupportedException:
			//     target is System.EnvironmentVariableTarget.User or System.EnvironmentVariableTarget.Machine
			//     and the current operating system is Windows 95, Windows 98, or Windows Me.
			//
			//   System.ArgumentException:
			//     target is not a valid System.EnvironmentVariableTarget value.
			//
			//   System.Security.SecurityException:
			//     The caller does not have the required permission to perform this operation.
			//[SecuritySafeCritical]
			public: static GC_PTR<string> GetEnvironmentVariable(string* variable, EnvironmentVariableTarget target);

			//
			// Summary:
			//     Retrieves all environment variable names and their values from the current
			//     process.
			//
			// Returns:
			//     A dictionary that contains all environment variable names and their values;
			//     otherwise, an empty dictionary if no environment variables are found.
			//
			// Exceptions:
			//   System.Security.SecurityException:
			//     The caller does not have the required permission to perform this operation.
			//
			//   System.OutOfMemoryException:
			//     The buffer is out of memory.
			//[SecuritySafeCritical]
			public: static GC_PTR<Collections::IDictionary> GetEnvironmentVariables();

			//
			// Summary:
			//     Retrieves all environment variable names and their values from the current
			//     process, or from the Windows operating system registry key for the current
			//     user or local machine.
			//
			// Parameters:
			//   target:
			//     One of the System.EnvironmentVariableTarget values.
			//
			// Returns:
			//     A dictionary that contains all environment variable names and their values
			//     from the source specified by the target parameter; otherwise, an empty dictionary
			//     if no environment variables are found.
			//
			// Exceptions:
			//   System.Security.SecurityException:
			//     The caller does not have the required permission to perform this operation
			//     for the specified value of target.
			//
			//   System.NotSupportedException:
			//     This method cannot be used on Windows 95 or Windows 98 platforms.
			//
			//   System.ArgumentException:
			//     target contains an illegal value.
			//[SecuritySafeCritical]
			public: static GC_PTR<Collections::IDictionary> GetEnvironmentVariables(EnvironmentVariableTarget target);

			//
			// Summary:
			//     Gets the path to the system special folder that is identified by the specified
			//     enumeration.
			//
			// Parameters:
			//   folder:
			//     An enumerated constant that identifies a system special folder.
			//
			// Returns:
			//     The path to the specified system special folder, if that folder physically
			//     exists on your computer; otherwise, an empty GC_PTR<string> ("").A folder will not
			//     physically exist if the operating system did not create it, the existing
			//     folder was deleted, or the folder is a virtual directory, such as My Computer,
			//     which does not correspond to a physical path.
			//
			// Exceptions:
			//   System.ArgumentException:
			//     folder is not a member of System.Environment.SpecialFolder.
			//
			//   System.PlatformNotSupportedException:
			//     The current platform is not supported.
			//[SecuritySafeCritical]
			public: static GC_PTR<string> GetFolderPath(Environment::SpecialFolder folder);

			//
			// Summary:
			//     Gets the path to the system special folder that is identified by the specified
			//     enumeration, and uses a specified option for accessing special folders.
			//
			// Parameters:
			//   folder:
			//     An enumerated constant that identifies a system special folder.
			//
			//   option:
			//     Specifies options to use for accessing a special folder.
			//
			// Returns:
			//     The path to the specified system special folder, if that folder physically
			//     exists on your computer; otherwise, an empty GC_PTR<string> ("").A folder will not
			//     physically exist if the operating system did not create it, the existing
			//     folder was deleted, or the folder is a virtual directory, such as My Computer,
			//     which does not correspond to a physical path.
			//
			// Exceptions:
			//   System.ArgumentException:
			//     folder is not a member of System.Environment.SpecialFolder
			//
			//   System.PlatformNotSupportedException:
			//     System.PlatformNotSupportedException
			//[SecuritySafeCritical]
			public: static GC_PTR<string> GetFolderPath(Environment::SpecialFolder folder, Environment::SpecialFolderOption option);

			//
			// Summary:
			//     Returns an array of GC_PTR<string> containing the names of the logical drives on
			//     the current computer.
			//
			// Returns:
			//     An array of strings where each element contains the name of a logical drive.
			//     For example, if the computer's hard drive is the first logical drive, the
			//     first element returned is "C:\".
			//
			// Exceptions:
			//   System.IO.IOException:
			//     An I/O error occurs.
			//
			//   System.Security.SecurityException:
			//     The caller does not have the required permissions.
			//[SecuritySafeCritical]
			public: static GC_PTR<Array<string>> GetLogicalDrives();

			//
			// Summary:
			//     Creates, modifies, or deletes an environment variable stored in the current
			//     process.
			//
			// Parameters:
			//   variable:
			//     The name of an environment variable.
			//
			//   value:
			//     A value to assign to variable.
			//
			// Exceptions:
			//   System.ArgumentNullException:
			//     variable is null.
			//
			//   System.ArgumentException:
			//     variable contains a zero-length string, an initial hexadecimal zero character
			//     (0x00), or an equal sign ("="). -or-The length of variable or value is greater
			//     than or equal to 32,767 characters.-or-An error occurred during the execution
			//     of this operation.
			//
			//   System.Security.SecurityException:
			//     The caller does not have the required permission to perform this operation.
			//[SecuritySafeCritical]
			public: static void SetEnvironmentVariable(string* variable, GC_PTR<string> value);

			//
			// Summary:
			//     Creates, modifies, or deletes an environment variable stored in the current
			//     process or in the Windows operating system registry key reserved for the
			//     current user or local machine.
			//
			// Parameters:
			//   variable:
			//     The name of an environment variable.
			//
			//   value:
			//     A value to assign to variable.
			//
			//   target:
			//     One of the System.EnvironmentVariableTarget values.
			//
			// Exceptions:
			//   System.ArgumentNullException:
			//     variable is null.
			//
			//   System.ArgumentException:
			//     variable contains a zero-length string, an initial hexadecimal zero character
			//     (0x00), or an equal sign ("="). -or-The length of variable is greater than
			//     or equal to 32,767 characters.-or-target is not a member of the System.EnvironmentVariableTarget
			//     enumeration. -or-target is System.EnvironmentVariableTarget.Machine or System.EnvironmentVariableTarget.User
			//     and the length of variable is greater than or equal to 255.-or-target is
			//     System.EnvironmentVariableTarget.Process and the length of value is greater
			//     than or equal to 32,767 characters. -or-An error occurred during the execution
			//     of this operation.
			//
			//   System.NotSupportedException:
			//     target is System.EnvironmentVariableTarget.User or System.EnvironmentVariableTarget.Machine
			//     and the current operating system is Windows 95, Windows 98, or Windows Me.
			//
			//   System.Security.SecurityException:
			//     The caller does not have the required permission to perform this operation.
			//[SecuritySafeCritical]
			public: static void SetEnvironmentVariable(string* variable, GC_PTR<string> value, EnvironmentVariableTarget target);
		};
	}
}

#endif